#pragma once
//============================================================================
// Copyright (C) 2003-2013 Brett R. Jones 
//
// Issued to public domain 2013
//
// brettjones1900@gmail.com
// http://www.p2panarchy.com
//============================================================================
// also you must link to  ws2_32.lib

#define VXSKT_INFO_SAMPLE_CNT 10
class VxSktSampleInfo
{
public:
	double m_dTime;
	unsigned long m_u32Bytes;
};

class VxSktInfo
{
public:
	VxSktInfo();

	double ComputeRxSpeedKbs( void );
	double ComputeTxSpeedKbs( void );
	void SetRxBandwidthLimitKbs( double dKbs ){ m_dRxSpeedLimit = dKbs; }
	void SetTxBandwidthLimitKbs( double dKbs ){ m_dTxSpeedLimit = dKbs; }
	BOOL TxBandwidthLimitReached() { return( m_dTxSpeedLimit && ( ComputeTxSpeedKbs() >= m_dTxSpeedLimit ))?1:0; }
	BOOL RxBandwidthLimitReached() { return( m_dRxSpeedLimit && ( ComputeRxSpeedKbs() >= m_dRxSpeedLimit ))?1:0; }
	double TxRemainingToLimit();
	double RxRemainingToLimit();
	void LogTxBytes( long s32ByteCnt );
	void LogRxBytes( long s32ByteCnt );
	void ResetTxInfo( void );
	void ResetRxInfo( void );

public:

	//statistics
	double	m_dTxSpeedLimit; 
	double	m_dRxSpeedLimit; 
	VxSktSampleInfo m_agTxSamples[VXSKT_INFO_SAMPLE_CNT];
	VxSktSampleInfo m_agRxSamples[VXSKT_INFO_SAMPLE_CNT];
	unsigned long m_u32TxSpeedIdx;
	unsigned long m_u32RxSpeedIdx;

	S64		m_i64BytesTxed;
	S64		m_i64BytesRxed;

	unsigned long m_u32TxPacketsDropped;
	unsigned long m_u32RxPacketsDropped;
	unsigned long m_u32TxPacketCnt;
	unsigned long m_u32RxPacketCnt;

	VxTimer m_oTimer;
};

